package com.tcm.service;

import com.tcm.config.AppProperties;
import com.tcm.entity.BattleItem;
import com.baomidou.mybatisplus.extension.service.IService;
import com.tcm.entity.bo.BattleItemExcel;
import com.tcm.entity.dto.BattleItemUpdateDto;
import com.tcm.entity.dto.param.BattleItemPageParam;
import com.tcm.entity.resp.PageR;
import com.tcm.entity.vo.*;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
* @author Guqier
* @description 针对表【ts_battle_item(PK对战题库主表)】的数据库操作Service
* @createDate 2023-09-10 14:24:47
*/
public interface BattleItemService extends IService<BattleItem> {

    @Transactional
    boolean addBattleItem(BattleItemUpdateDto dto, Long currUserId);

    @Transactional
    boolean modifyBattleItem(BattleItemUpdateDto dto, Long currUserId);

    @Transactional
    boolean removeBattleItem(List<Long> ids);

    @CacheEvict(value = AppProperties.ENTITY_CACHE_ITEM_BATTLE, key = "#id", condition = "#id != null")
    boolean removeBattleItemById(Long id);

    @Cacheable(value = AppProperties.ENTITY_CACHE_ITEM_BATTLE, key = "#id", unless = "#result == null")
    BattleItem getBattleItemById(Long id);

    PageR<BattleItemListResult> getBattleItemListByPage(BattleItemPageParam param);

    BatchImportResult<BattleItemExcel> importBattleItem(MultipartFile file) throws IOException;

    @Transactional
    boolean confirmBatchBattleItem(String uuid, Long currUserId);

    void exportImportFailedBattleItem(String uuid, HttpServletResponse response) throws Exception;

    void exportBattleItem(BattleItemPageParam param, HttpServletResponse response) throws IOException;

    BattleTopicResp transferBattleItemToTopicResp(BattleItem battleItem);

    BattleItemCorrectResp correctBattleItem(Long battleItemId, String ans);

    Boolean isMultiple(Long battleItemId);

    List<BattleItemDescribeResp> transferBattleItemToDescribeResp(List<BattleItem> battleItems);
}
